package server;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * class Server accepts incoming user requests and creates a thread with an
 * connection for each user.
 * 
 * @author Rasmus Stjerne, Joachim Lindholm, Daniel Gramstrup, Pamela Pedersen
 * 
 */
public class Server {
	/**
	 * Starting the server and keep accepting new user requests 
	 */
	public void runServer() {
		try {

			int serverPort = 7896;
			ServerSocket listenSocket = new ServerSocket(serverPort);
			// Inform the server has been started
			System.err.println("Server started!");
			while (true) {
				Socket clientSocket = listenSocket.accept();
				Connection c = new Connection(clientSocket);
				System.err.println("IP: " + clientSocket.getInetAddress()
						+ " connected");
			}
		} catch (IOException e) {
			System.out.println("Listen :" + e.getMessage());
		}

	}
}